<?php
declare (strict_types = 1);

namespace app\admin\controller;

use addons\Builder\facade\Builder;
use think\response\Json;

//该文件为自动生成，请按需修改
class Level extends Base
{
    //所有定义变量均为演示，请根据实际需求更改

    //主键，默认为id
    protected string $pk = 'id';

    //主模型
    protected string $model = '\app\common\model\Level';
      //追加虚拟字段
    protected  $append = [
        'level_text',
    ];


    public function index(): string
    {
        //构建表格数据
        return Builder::Table()
            ->autoStructure($this->model, $this->pk, 'barDemo,80',false,false)
            ->addRightButtons(['edit' => ['size' => '50%']])
            ->addSearch([
                ['title', '等级名称搜索', 'input,Like'],
            ],false)
            ->fetch();
    }

    public function save($param = [], $model = false): Json
    {
        $param = $this->request->post();
        $param['tp_1'] = $param['tp_1'] /100;
        return parent::save($param, $model); // TODO: Change the autogenerated stub
    }
}
